<?php
class ApiCenter_SalesApi_OrderController extends Mage_Core_Controller_Front_Action {
   
             public function printorderAction(){
                 $orderId = $this->getRequest()->getParam('order_id');
                 $currentVendorId = $this->getRequest()->getParam('vendor_id');
                 $type = $this->getRequest()->getParam('type',2);
//                  echo $type;
//                  die;
                 if($_order = Mage::getModel('salesapi/order')->load($orderId)){
                     $vendorCode      = Mage::getStoreConfig('vendors/sales/trackno_print_vendor_code');
                     $checkWord       = Mage::getStoreConfig('vendors/sales/trackno_print_checkword');
                     $incrementId     = $_order->getIncrementId();
                     $vendorId        = $_order->getVendorId();
                     if($vendorId == $currentVendorId){
                         $url = 'http://127.0.0.1:8080/rumall/exportWaybill';
                         $params = '';
                         $params .= '?xml=';
                         $params .= '<ExportWaybill>';
                         $params .= '<Checkword>'. $checkWord  .'</Checkword>';
                         $params .= '<CompanyCode>'. $vendorCode .'</CompanyCode>';
                         $params .= '<OrderId>'. $incrementId .'</OrderId>';
                         $params .= '<templateType>'. $type .'</templateType>';
                         $params .= '</ExportWaybill>';
						 Mage::log($params);
                         $attachment_location = file_get_contents($url . $params);
                         header('Content-Type: application/pdf');
                         header('filename="waybill_'.$incrementId.'_'.Mage::getSingleton('core/date')->date('Y-m-d_H-i-s').'.pdf"');
                         readfile($attachment_location);
                         print_r($attachment_location);
                     }else{
                         echo "VendorId is not current vendors!";
                        exit;
                     }
                 }else{
                     echo "Order id error!.";
                      exit;
                 }
             } 
}